/*
 * DxfFile.java
 *
 * Created on 6 de Dezembro de 2007, 10:46
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package importadorDXF;

import mathematics.Point3D;

/**
 *
 * @author rafaelbuck
 */
public class DxfSOLID extends DxfEntity
{

    /** Creates a new instance of DxfSOLID */
    public DxfSOLID()
    {
        corner = new Point3D[4];
        maxPointUsed = -1;
        corner[0] = new Point3D();
        corner[1] = new Point3D();
        corner[2] = new Point3D();
        corner[3] = new Point3D();
    }

    public boolean setGroup(short grpNr, float fval)
    {
        switch(grpNr)
        {
        case 10: // '\n'
        case 11: // '\013'
        case 12: // '\f'
        case 13: // '\r'
        case 20: // '\024'
        case 21: // '\025'
        case 22: // '\026'
        case 23: // '\027'
        case 30: // '\036'
        case 31: // '\037'
        case 32: // ' '
        case 33: // '!'
            setCoord(corner[grpNr % 10], grpNr / 10, fval);
            if(grpNr % 10 > maxPointUsed)
                maxPointUsed = (short)(grpNr % 10);
            return true;
        }
        return super.setGroup(grpNr, fval);
    }

    public boolean setGroup(short grpNr, int ival)
    {
        return super.setGroup(grpNr, ival);
    }

    protected void preConvert()
    {
        if(maxPointUsed < 3 && maxPointUsed > 0)
        {
            for(int p = maxPointUsed + 1; p < corner.length; p++)
                corner[p] = corner[maxPointUsed];

            maxPointUsed = 3;
        }
    }

    public void convert(DxfConverter converter, DxfFile dxf, Object collector)
    {
        preConvert();
        converter.convert(this, dxf, collector);
    }

    public final Point3D[] getCorners()
    {
        return corner;
    }

    protected Point3D corner[];
    protected short maxPointUsed;
}